#include <iostream>
#include <ctime>
using namespace std;

struct Student
{
	char* name;
	int id;
	float score;

	Student(){}
	void input (int id, char* name, float score)
	{
		this->id = id;
		this->score = score;
		this->name = new char[strlen(name)+1];
		strcpy(this->name, name);
	}
};

struct Class
{
	Student studentList[10];

	void add()
	{
		int id;
		char name[20];
		float score;
		for (int i=0; i < 10; ++i)
		{
			cout << "====" << i << "====" << endl << endl;
			cout << "id: ";
			cin >> id;
			cout << "name: ";
			cin.get();
			cin.getline(name, 20);
			cout << "score: ";
			cin >> score;

			if (!isDuplicated(id) && checkScore(score))
				studentList[i].input(id, name, score);
			else
			{
				cout << "wrong! Try again." << endl;
				--i;
			}
		}
	}

	bool isDuplicated(int id)
	{
		for (int i=0; i < 10; ++i)
		{
			if (studentList[i].id == id)
				return true;
		}
		return false;
	}

	bool checkScore(float score)
	{
		return (score >= 0 && score <= 10);
	}
	void sortbyScore()
	{
		int count = NUM_STUDENTS;
		while (count > 0)
		{
			for (int i = 0; i < count - 1; ++i)
			{
				if (studentList[i].score > studentList[i+1].score)
				{
					Student tmp = studentList[i];	
					studentList[i] = studentList[i+1];
					studentList[i+1] = tmp;
				}
			}
			count--;
		}
	}
};
void main()
{
	Class A;
	A.add();
}